package com.bgba.oer;

import java.util.Properties;
import java.util.ResourceBundle;

public class ResourceBundleHelper {

	
	    private static ResourceBundleHelper INSTANCE = new ResourceBundleHelper();
	
	    //private Properties registryUserBundle = new Properties();
	    
	    /**
	     * User Bundle de SharePoint
	     */
	    private ResourceBundle userBundle = null;

	    /**
	     * System Bundle de SharePoint
	     */
	    private ResourceBundle systemBundle = null;
	  	 
	    private ResourceBundleHelper() {
		    System.out.println("============================ ResourceBundleHelper()");
		    userBundle = ResourceBundle.getBundle("com.bgba.oer.SharepointUser");
		    //System.out.println("============================ user 55="+userBundle.getString("56"));
		    systemBundle = ResourceBundle.getBundle("com.bgba.oer.SharepointSystem");
		    //System.out.println("============================ system 13="+systemBundle.getString("13"));
		}
	 
	    public static ResourceBundleHelper getInstance() {
		    //System.out.println("============================ ResourceBundleHelper.getInstance()");
	        if (INSTANCE == null) 
		            INSTANCE = new ResourceBundleHelper();
	        return INSTANCE;
	    }	    
	    
	    /**
	     * 
	     * @param systemId - ID del sistema en SharePoint
	     * @return
	     */
	    public String getSharePointSystemName(String systemId){
		    //System.out.println("============================ ResourceBundleHelper.getSharePointSystemName()");
	    	return systemBundle.getString(systemId);
	    }
	    
	    /**
	     * 
	     * @param userId - ID del usuario en SharePoint
	     * @return
	     */
	    public String getSharePointUserName(String userId){
		    //System.out.println("============================ ResourceBundleHelper.getSharePointUserName()");
	    	return userBundle.getString(userId);
	    }

	    
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String systemName = ResourceBundleHelper.getInstance().getSharePointSystemName("15");
		System.out.println("========================= systemName="+systemName);
		String username = ResourceBundleHelper.getInstance().getSharePointUserName("43"); 
		System.out.println("========================= username="+username);
		
	}

}
